<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/19
 * Time: 14:19
 */

namespace app\index\controller;
use think\Db;

class News
{
    public function index($type_id)
    {
        $list = Db::name('news')
            ->where('auding_status',2)
            ->where('type_id',$type_id)
            ->where('is_delete',1)
            ->where('status',1)
            ->order('id desc')
            ->field('id,title,describe,pic_url')->paginate(8);
        return ['code' => 200,'message' => 'ok','data' => $list];
    }

    public function view($id)
    {
        $content = '<style> img {vertical-align:middle; width:auto; max-width:95%;} </style>';
        $content .= '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">';
        $content .= Db::name('news')->where('id',$id)->value('content');
        return response($content);
    }
}